<?php
$xtpl = new XTemplate($inner_templates."home.news.htm");

$xtpl->assign ("base_url", $base_url);
$page = $_GET['page'];
$limit = 10;
$pagegroup_size = 10;
if (!$page||$page==0){
	$page=1;
}
$offset = ($page-1)*$limit;
//////
/////////////////////////
$sql_c = "SELECT COUNT(*) AS total_msg FROM {$DP}news WHERE id_lang=".$_SESSION['ID_LANG'];
$rs_c = mysql_query($sql_c);
list($numrec)=mysql_fetch_row($rs_c);
//////////////////////////
$title = "";
if($_GET['id']){
	$row = $DB->FetchData('news','*',"WHERE news_id='".$_GET['id']."' AND id_lang=".$_SESSION['ID_LANG']);
	$row['title']=stripslashes($row['news_title']);
	$row['shortdes']=stripslashes($row['news_shortdes']);
	$row['id'] = $row['news_id'];
	$row['date'] = date('d-m-Y',strtotime($row['news_date']));
	$row['content'] = stripslashes($row['news_content']);
	$title = $row['title'];
	if($row['news_image']!=''){	
		if(file_exists('upload/news/thumb'.$row['news_image'])){
			$row['image']='<img src="'.$base_url.'upload/news/thumb'.$row['news_image'].'" border="0" />';
		}
		else{
			$row['image']='<img src="'.$base_url.'upload/news/unavail.gif" width="120" border="0" />';
		}
	}
	//$rs = $DB->ZenDataList('news','',"news_status='1' AND news_date < '".$row['news_date']."'",'news_date DESC ','0,10');
	$sql="SELECT * FROM {$DP}news WHERE news_status=1 AND id_lang = '".$_SESSION['ID_LANG']."' AND (news_date < '" .$row['news_date']. "' OR news_date = '" .$row['news_date']. "') ORDER BY news_date DESC  LIMIT 0,10";
	$rs=mysql_query($sql);
	while($row1 = mysql_fetch_array($rs)){
                $row1['url_html'] = RemoveSign($row1['news_title']).".html";
		$row1 = '<li><a class="small_link" href="'.$base_url. _LB_MOD_NEWS .'/'.$row1['news_id'].'/'.$row1['url_html'].'">'.stripslashes($row1['news_title']).'</a></li>';
		$xtpl->assign("title",$row1);
		$xtpl->parse("center.detail.list");
	}
	$xtpl->assign("list",$row);
	$xtpl->parse("center.detail");
        
}else{
	$rs = $DB->ZenDataList('news','',"news_status='1' AND id_lang='".$_SESSION['ID_LANG']."'",'news_date DESC ',$offset.','.$limit);
	while($row = mysql_fetch_array($rs)){
		$row['title']=stripslashes($row['news_title']);
		$row['id'] = $row['news_id'];
		$row['date'] = date('d-m-Y',strtotime($row['news_date']));
		$row['shortdes']=stripslashes($row['news_shortdes']);
                $row['url_html'] = RemoveSign($row['news_title']).".html";
		if($row['news_image']!=''){	
			if(file_exists('upload/news/thumb'.$row['news_image'])){
				$row['image']='<img src="'.$base_url.'upload/news/thumb'.$row['news_image'].'" border="0" />';
			}
			else{
				$row['image']='<img src="'.$base_url.'upload/news/unavail.gif" width="120" border="0" />';
			}
		}
		$xtpl->assign("list",$row);
		$xtpl->parse("center.list");
	}
    $pages = pagenavigator($page,$numrec,$limit,$pagegroup_size,"row0",$base_url._LB_MOD_NEWS."/");
    $xtpl->assign("page",$page);
    $xtpl->assign("pages",$pages);
    $xtpl->assign("numrec",$numrec);
    $xtpl->parse("center.pagination");
	$title = _LB_NEWS;
}
$xtpl_main->assign ("page_title", $title);
//--
include $rootPath.'modules/home/left.support_online.php';
?>
